home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 February / Macworld (1999-02).dmg / Shareware World / Shareware Feature / PageSpinner 2.0.1 / Examples / JavaScript / Timed_Banner < prev    next >
Text File  |  1997-06-17  |  4KB  |  136 lines

  1. <HTML><HEAD>
  2. <TITLE>JavaScript Banner</TITLE>
  3.  
  4. <SCRIPT LANGUAGE="JavaScript">
  5. <!-- Beginning of JavaScript --------
  6. /* 
  7.     JavaScript Banner
  8.     Written by Jerry Aman, Optima System, April 19, 1997.
  9.     Part of the PageSpinner distribution.
  10.  
  11.     We will not be held responsible for any unwanted 
  12.     effects due to the usage of this script or any derivative.  
  13.     No warrantees for usability for any specific application are 
  14.     given or implied.
  15.  
  16.     You are free to use and modify this script,
  17.     if the credits above are given in the source code
  18. */
  19.  
  20. var    timerID = null;
  21. var    timerRunning = false;
  22.  
  23. function stopclock()
  24. {
  25.     if(timerRunning)
  26.         clearTimeout(timerID)
  27.         timerRunning = false
  28. }
  29.  
  30. function startclock()
  31. {
  32.     stopclock()
  33.     showMessage()
  34. }
  35.  
  36.  
  37. var messageList = new msgList (
  38.     "Spin a Wonderful Web With PageSpinner!",
  39.     "PageSpinner can be yours for ONLY $25",
  40.     "Write JavaScript with PageSpinner!",
  41.     "Learn HTML with PageSpinner!",
  42.     "And tell PageSpinner to use...",
  43.     "AppleScript to automate tediuos tasks!",
  44.     "PageSpinner for MacOS",
  45.     "ONLY $25",
  46.     "Get it now and...",
  47.     "Spin a Wonderful Web With PageSpinner!",
  48.     "Create Forms with PageSpinner!",
  49.     "Write JavaScript with PageSpinner!",
  50.     "Learn HTML with PageSpinner!",
  51.     "Publish Databases with AppleScript and ...",
  52.     "Create Cascading Style Sheets and ..."
  53.     );
  54.  
  55.  
  56. function GetNextMessage()
  57. {
  58.     messageList.selected ++;
  59.  
  60.     if ( messageList.selected >=  messageList.count)
  61.          messageList.selected = 0;
  62.  
  63.     return  messageList.list[messageList.selected];
  64. }
  65.  
  66.  
  67.  
  68. function msgList ()
  69. {
  70.     var argv = msgList.arguments;
  71.     var argc = argv.length;
  72.     this.list = new Object();
  73.     for (var i = 0; i < argc; i++)
  74.     this.list[i] = argv[i];
  75.     this.count = argc;
  76.     this.selected = -1;
  77.     return this;
  78. }
  79.  
  80.  
  81. /*    -------------------------------------------------
  82.     showMessage()
  83.     Display message in field named timerField in 
  84.     the form named timeForm 
  85.     -------------------------------------------------    */
  86.  
  87. function showMessage()
  88. {
  89.         // Update display every 2000 ms
  90.     document.timerForm.timerField.value =  " " + GetNextMessage ();
  91.     timerID = setTimeout("showMessage()",2000);
  92.     timerRunning = true;
  93. }
  94.  
  95. // -- End of JavaScript code -------------- -->
  96. </SCRIPT>
  97.  
  98. </HEAD>
  99. <BODY onLoad="startclock()">
  100. <H1>JavaScript Banner</H1>
  101.  
  102. <B>This stationery page contains a JavaScript Banner Example</B>
  103. <P>
  104. Please note that JavaScript is currently only available in Netscape Navigator 2.0 or higher. <BR>
  105. <FONT COLOR="931B15">Do not assume that all in your audience are using a JavaScript enabled browser.</FONT>
  106. <HR>
  107. <P>
  108.  
  109. <CENTER><FORM NAME="timerForm" onSubmit="0">
  110. <INPUT TYPE="text" NAME="timerField" SIZE=45 VALUE ="">
  111. </FORM>
  112. </CENTER>
  113. <P>
  114. <HR>
  115. <P>
  116. <B>How to use:</B>
  117. <BLOCKQUOTE>
  118. <P>
  119. Copy all JavaScript (located in the Head section of this file) to another file. You can also use this file as a stationery. 
  120. <P>
  121. Use the following Body tag <CODE><BODY  onLoad="startclock()"></CODE> to start the timer that is used for updating the field with new messages.
  122. <P>
  123. Use something like this inside the Body  part of your page to display the banner.
  124.  
  125. <XMP><FORM NAME="timerForm" onSubmit="0">
  126. <INPUT TYPE="text" NAME="timerField" SIZE=45 VALUE ="">
  127. </FORM>
  128. </XMP>
  129.  
  130. Adjust the size of the text field in the attribute named <CODE>SIZE=40</CODE>, remember to add some extra space or test it in different browsers to make sure the longest of your messages is fully visible.
  131. </BLOCKQUOTE>
  132.  
  133. Another way of displaying different messages is to use animated GIF-images. This will give you more graphical control of the display and can even be used to create simple movies. Use an application such as GIFBuilder to create animated GIF-images.
  134. </BODY>
  135. </HTML>
  136.